#include "enemybullet.h"
enemybullet::enemybullet()
{
    //加载子弹资源
    m_enemybullet.load(ENEMY_BULLET_PATH);
    //子弹坐标 初始坐标可随意设置，后期会重置
    m_X = GAME_WIDTH*0.5 - m_enemybullet.width()*0.5;
    m_Y = GAME_HEIGHT;
    //子弹状态
    m_Free = true;
    //子弹速度
    m_Speed = ENEMY_BULLET_SPEED;

    //子弹矩形框
    m_Rect.setWidth(m_enemybullet.width());
    m_Rect.setHeight(m_enemybullet.height());
    m_Rect.moveTo(m_X,m_Y);

}
 void enemybullet::updatePosition() {
    if(m_Free) {
        return;
}
    //子弹向下移动
    m_Y  += m_Speed;
    m_X +=m_Speed*0.5;
    m_Rect.moveTo(m_X,m_Y);
    if(m_Y >800)
    {
        m_Free = true;
    }
}
